package MemberAction;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import DAO.MemberDAO;

public class MemberDeleteAction implements MemAction {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		HttpSession session;
		session = request.getSession();
		MemberDAO dao = new MemberDAO();
		MemberDAO dao1 = null;
		PrintWriter out = null;

		String pw = request.getParameter("pw");
		String id = (String) session.getAttribute("id");

		boolean flag = dao.login(id, pw);
		String page = "";
		try {
			if (flag) {
				dao1 = new MemberDAO();
				dao1.memDelete(id);
				page = "./member/member_out_ok.jsp";
			} else {
				page = "./member/member_out_not.jsp";
			}
			response.sendRedirect(page);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
